package edu.gdpu.bytecode;

/**
 * @author mazebin
 * @date 2021年 07月09日 00:21:11
 * 方法的动态分派
 * 在动态分派中虚拟机是如何知道要调用那个方法的？
 */
public class ByteCodeTest5 {
    static abstract class Human{
        public abstract void hello();
        public  void hello(String hello){
            System.out.println(hello);
        }
    }
    static class Man extends Human{
        @Override
        public void hello() {
            System.out.println("hello man");
        }
    }
    static class Woman extends Human{

        @Override
        public void hello() {
            System.out.println("hello woman");
        }
    }

    public static void main(String[] args) {
        Human woman = new Woman();
        Human man = new Man();
        woman.hello();
        woman.hello("hello world");
        man.hello();
        man = new Woman();
        man.hello();

        /**
         * hello woman
         * hello man
         * hello world
         * hello woman
         */
    }
}
